import Taro, {Component} from '@tarojs/taro'
import { AtGrid } from "taro-ui"
import {View} from "@tarojs/components"
import {navigateWithAuth} from "../../utils";
import './index.scss'

export default class Index extends Component {
    constructor(props) {
        super(props);
      this.navigateToTools = this.navigateToTools.bind(this);
      this.state = {
            current: 0
        }
    }

  componentDidMount () {
    Taro.setNavigationBarTitle({
      title:'工具'
    })
  }
  navigateToTools(item,index){
      console.log(item)
      switch (index) {
        case 0:
          navigateWithAuth('/pages/tools/createNotice/index')
              break;
        case 1:
          navigateWithAuth('/pages/tools/createHomework/index')
          break;
        case 2:
          navigateWithAuth('/pages/tools/uploadFiles/index')
          break;
        case 3:
          navigateWithAuth('/pages/tools/sign/index')
          break;
        case 4:
          navigateWithAuth('/pages/tools/askForBreak/index')
          break;

      }
  }

  render() {
    const toolList = [
      {
        iconInfo:{ size: 25, prefixClass:'icon', value: 'tongzhi1' },
        value: '发布通知'
      },{
        iconInfo:{ size: 25, prefixClass:'icon', value: 'zuoye1' },
        value: '发布作业'
      },{
        iconInfo:{ size: 25, prefixClass:'icon', value: 'shangchuanwenjian' },
        value: '上传文件'
      },{
        iconInfo:{ size: 25, prefixClass:'icon', value: 'lujingcaxun-' },
        value: '定位签到'
      },
      {
        iconInfo:{ size: 25, prefixClass:'icon', value: 'qingjia' },
        value: '便捷请假'
      }
      ]
      return(
        <View>
          <AtGrid
            data={toolList}
            onClick={this.navigateToTools}
          />
        </View>
      )
  }
}
